package com.coolw.cola.statemachine.support;

import com.alibaba.cola.statemachine.Action;
import com.coolw.cola.statemachine.dto.Order;
import com.coolw.cola.statemachine.enums.OrderEvent;
import com.coolw.cola.statemachine.enums.OrderStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 用户关闭订单Action,订单状态变化后执行
 *
 * @author coolw
 * @date 2024/4/9 14:03
 */
@Slf4j
@Component
public class CloseOrderAction implements Action<OrderStatusEnum, OrderEvent, Order> {

    @Override
    public void execute(OrderStatusEnum from, OrderStatusEnum to, OrderEvent event, Order context) {
        log.info("关闭订单流程开始");
        log.info("from:{}, to:{}", from, to);
        log.info("event:{}", event);
        log.info("context:{}", context);
        log.info("关闭订单流程结束");

        // 业务处理......（比如更新订单状态）
    }
}
